﻿using System;
using System.ApplicationModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace Anagramme.Services
{
    /// <summary>
    /// Trace source service
    /// </summary>
    public sealed class TraceService : IApplicationService, IApplicationLifetimeAware, Anagramme.Services.ITraceService
    {
        /// <summary>
        /// Get the main application trace source
        /// </summary>
        public TraceSource Source { get; private set; }

        #region IApplicationService
        /// <summary>
        /// Called by an application in order to initialize the application extension service. 
        /// </summary>
        /// <param name="context">Provides information about the application state. </param>
        public void StartService(ApplicationServiceContext context)
        {
            Source = new TraceSource("defaultSource");
        }

        /// <summary>
        /// Called by an application in order to stop the application extension service. 
        /// </summary>
        public void StopService()
        {
            Source.Flush();
            Source.Close();
        }
        #endregion

        #region IApplicationLifetimeAware
        /// <summary>
        /// Called by an application immediately after the <see cref="System.Windows.Application.Exit"/> event occurs. 
        /// </summary>
        public void Exited()
        {

        }

        /// <summary>
        /// Called by an application immediately before the <see cref="System.Windows.Application.Exit"/> event occurs. 
        /// </summary>
        public void Exiting()
        {

        }

        /// <summary>
        /// Called by an application immediately after the <see cref="System.Windows.Application.Startup"/> event occurs. 
        /// </summary>
        public void Started()
        {

        }

        /// <summary>
        /// Called by an application immediately before the <see cref="System.Windows.Application.Startup"/> event occurs. 
        /// </summary>
        public void Starting()
        {

        }
        #endregion
    }
}
